<?php

require_once 'facebook.php';

$appapikey = '81365d6aeb0cdffb943b9e75d062462f'; // you have to change this - put yours
$appsecret = '7da3447c27779ddfadf01127a9d7945a'; // you have to change this - put yours
$infinite_session_key = 'PASTE_YOUR_INFINITE_SESSION_KEY_HERE'; // you have to change this - put yours

$appcallbackurl = 'http://apps.facebook.com/facebook_video/'; // you have to change this - put yours
$app_name = "Googlewala.com Rocks- Best Videos";

$facebook = new Facebook($appapikey, $appsecret);
$facebook->require_frame();
$user = $facebook->require_login();

//catch the exception that gets thrown if the cookie has an invalid session_key in it
try {
  if (!$facebook->api_client->users_isAppAdded()) {
      $facebook->redirect($facebook->get_add_url());
  }
} catch (Exception $ex) {
  //this will clear cookies for your application and redirect them to a login prompt
  $facebook->set_user(null, null);
  $facebook->redirect($appcallbackurl);
}


//finding facebook user details of facebook user.
$user_details = $facebook->api_client->fql_query("SELECT uid, first_name, last_name FROM user WHERE uid=$user");
$facebook_uid = $user_details[0]['uid'];
$facebook_first_name = $user_details[0]['first_name'];
$facebook_last_name = $user_details[0]['last_name'];

// setting default text and application info to facebook users profile -- Change url and names and image path.
$fbml = '<fb:subtitle>
      <fb:action href="http://apps.facebook.com/facebook_video/index.php">Is this Amazing</fb:action>
  <fb:action href="http://apps.facebook.com/facebook_video/invite.php">Invite Your Friends</fb:action>
 </fb:subtitle>
<a href="http://apps.facebook.com/facebook_video/index.php"><div align="center"><img src="http://googlewala.com/facebook_video/images/youtube2.jpg" alt="Our Lady"></div></a>';
$facebook->api_client->profile_setFBML($fbml, $user);
return $fbml;

// default mini feed code goes here
$feed_title = '<fb:name uid="'.$user.'"/> likes '.$app_name.' Application and you!';
$feed_body = 'O.O';
$facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body);


// Connection settings for local machine

	$hostname="p50mysql233.secureserver.net";
	$user="facebook_allapp";
	$pass="Buddha@123";
	$database="facebook_allapp";
	
	// SELECT An User and Pass for Admin Area
	$AdminUsername="purab";
	$AdminPassword="buddha";

	// Your Domain Name
	$domain="Googlewala.com";

  @mysql_connect($hostname,$user,$pass) or die(mysql_error());
  @mysql_select_db($database) or die(mysql_error());	


?>